package com.matt.sooncleaner.launcher

import com.blankj.utilcode.util.ToastUtils
import com.matt.sooncleaner.BuildConfig
import com.matt.sooncleaner.R
import com.matt.sooncleaner.arch.ArchFragment
import com.matt.sooncleaner.databinding.FragmentPrivacyPolicyBinding
import com.matt.sooncleaner.web.WebViewActivity

class PrivacyPolicyFragment(val showNext: ()->Unit) : ArchFragment<FragmentPrivacyPolicyBinding>() {

    override fun onInitView(binding: FragmentPrivacyPolicyBinding) {
        super.onInitView(binding)
        binding.privacyPolicy.paint.isUnderlineText = true
        binding.startBtn.setOnClickListener {
            if (!binding.privacyPolicyCheckbox.isChecked) {
                ToastUtils.showLong(R.string.privacy_policy_agree_toast)
                return@setOnClickListener
            }
            requireContext().setAlreadyUsed()
            showNext.invoke()
        }
        binding.privacyPolicy.setOnClickListener {
            WebViewActivity.startWebViewActivity(requireContext(),
                BuildConfig.PRIVACY_POLICY_URL, getString(R.string.privacy_policy))
        }
    }
}